# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=django
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=5.2.1
pkgrel=1
pkgdesc="A high-level Python Web framework that encourages rapid development and clean design (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.djangoproject.com/'
msys2_repository_url='https://github.com/django/django/'
msys2_references=(
  'archlinux: python-django'
  'purl: pkg:pypi/django'
  "cpe: cpe:/a:djangoproject:django"
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-asgiref"
         "${MINGW_PACKAGE_PREFIX}-python-sqlparse"
         "${MINGW_PACKAGE_PREFIX}-python-tzdata")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-bcrypt"
             "${MINGW_PACKAGE_PREFIX}-python-argon2_cffi")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-bcrypt: for bcrypt support"
            "${MINGW_PACKAGE_PREFIX}-python-argon2_cffi: for Argon2 support")
options=('!strip')
source=(#"Django-${pkgver}.tar.gz"::"https://www.djangoproject.com/download/${pkgver}/tarball/"
        https://github.com/django/django/archive/${pkgver}/${_realname}-${pkgver}.tar.gz)
sha512sums=('7485317eb046fa42cdb807436128d5dee75f4aa3954583a7573781a9d3541d758bca706653972c78cec7c46efe7e694f472c0ba2cf35cbdeb890ce52cf453883')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  tar -xzf "${srcdir}"/${_realname}-${pkgver}.tar.gz || true
}

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
